public class Digits {
    public static void main(String[] args) {
        System.out.println(sum(1234));
    }
    public static void digit(int n){
        if(n/10>0){
            digit(n/10);
            System.out.print(n%10);
            System.out.print(' ');
        }else{
            System.out.print(n);
            System.out.print(' ');
        }
    }

    public static int sum(int n){
        if(n/10>0){
              return sum(n/10)+(n%10);
        }else{
            return n;
        }
    }
}
